// Copyright (c) ZeroC, Inc.

using GreeterServer;
using IceRpc;
using Microsoft.Extensions.Logging;
using VisitorCenter;

using ILoggerFactory loggerFactory = LoggerFactory.Create(builder =>
    builder
        .AddSimpleConsole()
        .AddFilter("IceRpc", LogLevel.Information));

var callbackConnection = new CallBackConnection();
// Create a server that dispatches all requests to the same service, an instance of Chatbot.
var chatbot = new Chatbot(callbackConnection);

Router router = new Router()
    .UseLogger(loggerFactory)
    .UseDispatchInformation()
    .Map<IGreeterService>(chatbot);

await using var server = new Server(router,new Uri("icerpc://[::0]:10010"),logger:loggerFactory.CreateLogger<Server>());
var serveraddress = server.Listen();

Console.WriteLine(serveraddress.ToString());

// Wait until the console receives a Ctrl+C.
await CancelKeyPressed;
await server.ShutdownAsync();
